package com.lp;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class TcpClient {
    public static void main(String[] args) {
        String serverIp = "192.168.1.7"; // 目标IP地址
        int serverPort = 20108; // 目标端口
        String message = "8613196660066:0:Hello, Server!"; // 要发送的消息

        try (Socket socket = new Socket(serverIp, serverPort)) {
            System.out.println("Connected to server at " + serverIp + ":" + serverPort);

            // 获取输出流
            OutputStream outputStream = socket.getOutputStream();

            // 发送数据
            outputStream.write(message.getBytes());
            outputStream.flush();

            System.out.println("Message sent: " + message);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
